Package com.netscape.cmscore.ldapconn
Class LdapBoundConnFactory
java.lang.Object
com.netscape.certsrv.ldap.LdapConnFactory
com.netscape.cmscore.ldapconn.LdapBoundConnFactory
Factory for getting LDAP Connections to a LDAP server with the same
LDAP authentication.
Maintains a pool of connections to the LDAP server.
CMS requests are processed on a multi threaded basis.
A pool of connections then must be be maintained so this
access to the Ldap server can be easily managed. The min and
max size of this connection pool should be configurable. Once
the maximum limit of connections is exceeded, the factory
should provide proper synchronization to resolve contention issues.
XXX not sure how useful this is given that LDAPConnection itself can
be shared by multiple threads and cloned.
-
Field Summary
FieldsFields inherited from class com.netscape.certsrv.ldap.LdapConnFactory
id, logger, mConnInfo, mDefErrorIfDown, mErrorIfDown, mMaxConns, mMaxResults, mMinConns, mNumConns, mTotal, PROP_ERROR_IF_DOWN, PROP_MAXCONNS, PROP_MAXRESULTS, PROP_MINCONNS, socketFactory
-
Constructor Summary
ConstructorsConstructorDescriptionConstructor for initializing from the config store.LdapBoundConnFactory
(String id, boolean defErrorIfDown) LdapBoundConnFactory
(String id, int minConns, int maxConns, int maxResults, LdapConnInfo connInfo, LdapAuthInfo authInfo) Constructor for LdapBoundConnFactoryLdapBoundConnFactory
(String id, int minConns, int maxConns, LdapConnInfo connInfo, LdapAuthInfo authInfo) Constructor for LdapBoundConnFactory -
Method Summary
Modifier and TypeMethodDescriptionreturn ldap authentication infonetscape.ldap.LDAPConnection
getConn()
gets a conenction from this factory.getConn
(boolean waitForConn) Returns a LDAP connection - a clone of the master connection.void
init()
initialize parameters obtained from either constructor or config storevoid
init
(LDAPConfig dbConfig) protected void
makeConnection
(boolean errorIfDown) makes the initial master connection used to clone others..void
reset()
used for disconnecting all connections and reset everything to 0 as if connections were never made.void
returnConn
(netscape.ldap.LDAPConnection conn) Teturn connection to the factory.void
setPasswordStore
(PasswordStore passwordStore) void
shutdown()
Methods inherited from class com.netscape.certsrv.ldap.LdapConnFactory
finalize, freeConn, getConnInfo, getSocketFactory, maxConn, setSocketFactory, totalConn
-
Field Details
-
PROP_LDAPCONNINFO
- See Also:
-
PROP_LDAPAUTHINFO
- See Also:
-
-
Constructor Details
-
LdapBoundConnFactory
Constructor for initializing from the config store. must be followed by init(ConfigStore) -
LdapBoundConnFactory
-
LdapBoundConnFactory
public LdapBoundConnFactory(String id, int minConns, int maxConns, LdapConnInfo connInfo, LdapAuthInfo authInfo) throws ELdapException Constructor for LdapBoundConnFactory- Parameters:
minConns
- minimum number of connections to have availablemaxConns
- max number of connections to have available. This is the maximum number of clones of this connection or separate connections one wants to allow.connInfo
- server connection info - host, port, etc.- Throws:
ELdapException
-
LdapBoundConnFactory
public LdapBoundConnFactory(String id, int minConns, int maxConns, int maxResults, LdapConnInfo connInfo, LdapAuthInfo authInfo) throws ELdapException Constructor for LdapBoundConnFactory- Parameters:
minConns
- minimum number of connections to have availablemaxConns
- max number of connections to have available. This is the maximum number of clones of this connection or separate connections one wants to allow.maxResults
- max number of results to return per queryconnInfo
- server connection info - host, port, etc.- Throws:
ELdapException
-
-
Method Details
-
init
- Throws:
EBaseException
ELdapException
-
init
initialize parameters obtained from either constructor or config store- Throws:
ELdapException
-
makeConnection
makes the initial master connection used to clone others..- Throws:
ELdapException
- if any error occurs.
-
getConn
gets a conenction from this factory. All connections obtained from the factory must be returned by returnConn() method. The best thing to do is to put returnConn in a finally clause so it always gets called. For example,LDAPConnection c = null; try { c = factory.getConn(); myclass.do_something_with_c(c); } catch (ELdapException e) { handle_error_here(); } finally { factory.returnConn(c); }
- Specified by:
getConn
in classLdapConnFactory
- Returns:
- Ldap connection object. connection is not available
- Throws:
ELdapException
- if any error occurs, such as a
-
getConn
Returns a LDAP connection - a clone of the master connection. All connections should be returned to the factory using returnConn() to recycle connection objects. If not returned the limited max number is affected but if that number is large not much harm is done. Returns null if maximum number of connections reached. The best thing to do is to put returnConn in a finally clause so it always gets called. For example,LDAPConnection c = null; try { c = factory.getConn(); myclass.do_something_with_c(c); } catch (ELdapException e) { handle_error_here(); } finally { factory.returnConn(c); }
- Throws:
ELdapException
-
returnConn
public void returnConn(netscape.ldap.LDAPConnection conn) Teturn connection to the factory. This is mandatory after a getConn(). The best thing to do is to put returnConn in a finally clause so it always gets called. For example,LDAPConnection c = null; try { c = factory.getConn(); myclass.do_something_with_c(c); } catch (ELdapException e) { handle_error_here(); } finally { factory.returnConn(c); }
- Specified by:
returnConn
in classLdapConnFactory
- Parameters:
conn
- Ldap connection object to be returned to the free list of the pool.
-
reset
used for disconnecting all connections and reset everything to 0 as if connections were never made. used just before a subsystem shutdown or process exit. useful only if no connections are outstanding.- Specified by:
reset
in classLdapConnFactory
- Throws:
ELdapException
-
shutdown
- Throws:
ELdapException
-
getAuthInfo
return ldap authentication info -
getPasswordStore
-
setPasswordStore
-